<extend name="Layout:layout_list" />
<block name="body_before_block">
    <script src="__THEME__Plugin/jquery-gridtimer-1.0/jquery-gridtimer-1.0.js" type="text/javascript"></script>
</block>
<block name="body_content_block">
    <div style="width:1160px; height:475px; overflow-y: hidden;">
        <div style="position: relative; width:800px; float:left;">  
            <table id="main_grid" class="easyui-datagrid" data-url="{:AddonU('Status/get_trunk_status_list_json')}"></table>
            <div id="tb" style="padding:2px 5px;">
                <table>
                    <tr><td style="width:650px;"><span id="sum"></span></td><td style="width:60px;"><a href="#" class="easyui-linkbutton lnk_grid_search" iconCls="icon-search" plain="true">搜索</a></td><td><input type="text" id="grid-timer" value="0" /></td></tr>
                </table>
            </div>
            <!--隐藏区域-->
            <div style="display:none">
                <!--表格查询对话框-->
                <div id="dlg_search" style="padding:10px">
                    <form method="get" action="{:AddonU('Status/get_trunk_status_list_json')}">
                        中继名称：<select name="trunkName" id="trunkName" class="easyui-combobox" data-url="{:AddonU('Trunk/get_json')}" data-target-url="{:AddonU('Status/trunk_status')}"></select>
                    </form>
                </div>
                <!--/表格查询对话框-->
            </div>
        </div>
        <!--/隐藏区域-->    
        <!--
        <div class="cdr-view" style="width:640px; float:left; margin-left:5px;">
            <iframe style="width:100%; overflow:hidden; height:475px;" frameborder="0" scrolling="no" src="{:AddonU('Statics/call_history_lite')}"></iframe>
        </div>
        -->
        <div style="clear:both;"></div>
    </div>
    <span id="cdr_view" style="display:none;">&nbsp;&nbsp;<a href="{:AddonU('Statics/call_history_lite')}" data-size='{"width":580,"height":545}' data-title="今日通话详单" onclick="return show_info(this);">[今日通话详单]</a></span>
</block>
<block name="body_after_block">
    <script type="text/javascript">
        // 页面初始化
        var curd_grid = CurdGrid.newInstance();
        curd_grid.before_search_dialog = function () {
            $('#trunkName').combobox({url: $('#trunkName').data('url'), valueField: 'id', textField: 'text'});
        }
        curd_grid.config({
            title: '当前通话' + $('#cdr_view').html(),
            toolbar: '#tb',
            onLoadSuccess: function (data) {
                $('#sum').html(data.sum);
            },
            columns: [[
                    {field: 'ck', checkbox: true},
                    {title: "中继名称", field: "trunk", sortable: true},
                    {title: "主叫号码", field: "caller", sortable: true},
                    {title: "被叫号码", field: "called"},
                    {title: "状态", field: "state", sortable: true},
                    {title: "持续时间", field: "duration", sortable: true},
                    {title: "租户", field: "siteIDText", sortable: true},
                ]],
        });
        curd_grid.init();
        $('.panel-title').html('panel-title');
        $(document).ready(function () {
            $('#grid-timer').gridTimer({elapsed: function () {
                    $('#main_grid').datagrid('reload');
                }});
        })
        // 2015-3-27 SoChishun Added.
        function handup(a) {
            var url = $(a).attr('href');
            if (url) {
                $.get(url, function (data) {
                    if (data.status) {
                        curd_grid.reload_grid();
                    } else {
                        alert(data.info);
                    }
                })
            }
            return false;
        }
        function show_info(a) {
            curd_grid.lnk_info_event(a);
            return false;
        }
    </script>
</block>